package portfelo.testing;

import java.util.Scanner;

import portfelo.db.QueryDB;
import portfelo.dto.PhotoDto;
import portfelo.dto.TagDto;
import portfelo.dto.AccountDto;

public class QueryDBTest {
	private static QueryDB query;
	public static void main(String[] args)
	{
		begin();
	}
	
	private static void begin() 
	{
		Scanner input = new Scanner(System.in);
		query = new QueryDB();
		boolean quit = false;
		PhotoDto t = query.getCurrentImage();
		testingImageGetting(t);
		TagDto o = query.getCurrentTag();
		testingTagGetting(o);
		while(!quit)
		{
			System.out.println("type your command: (up, down, left, or right)");
			String l = input.nextLine();
			if(l.equalsIgnoreCase("up"))
				nextTag();
			if(l.equalsIgnoreCase("down"))
				previousTag();
			if(l.equalsIgnoreCase("left"))
				previousImage();
			if(l.equalsIgnoreCase("right"))
				nextImage();
		}
	}

	private static void nextImage() 
	{
		PhotoDto t = query.getNextImage();
		testingImageGetting(t);
		
	}

	private static void previousImage() 
	{
		PhotoDto t = query.getPreviousImage();
		testingImageGetting(t);
		
	}

	private static void nextTag() 
	{
		query.setNextTag();
		TagDto o = query.getCurrentTag();
		testingTagGetting(o);
	}
	
	private static void previousTag() 
	{
		query.setPreviousTag();
		TagDto o = query.getCurrentTag();
		testingTagGetting(o);
	}


	//comment out what you don't want to print to save space in console
	public static void testingImageGetting(PhotoDto o)
	{
		System.out.println("CURRENT IMAGE INFO IS");
		System.out.println(" photo id " + o.getPhotoId());
		System.out.println(" account id " + o.getAccountId());
		System.out.println(" date taken " + o.getDateTakenDisplayString());
		System.out.println(" fqn " + o.getFullyQualifiedName());
		System.out.println(" location " + o.getLocation());
		System.out.println(" title " + o.getTitle());
		System.out.println(" date taken 2 " + o.getDateTaken());
//		System.out.println(" um " + o.getPhotoTagList()); 
		System.out.println(" tag size " + o.getPhotoTagList().size());
		
	}
	
	public static void testingTagGetting(TagDto o)
	{
		System.out.println("CURRENT Tag INFO IS");
		System.out.println(" photo id " + o.getPhotoId());
		System.out.println(" role " + o.getRole());
		System.out.println(" tag id " + o.getTagId());
//		System.out.println(" account " + o.getAccountDto());
	}
}
